/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ExitScreen.java
 *
 * Created on 29/03/2009, 22:02:20
 */

package NewGUI;

import java.awt.Component;
import java.io.IOException;

import scrabbleMain.GameGui;

/**
 *
 * @author Roy
 */
public class ExitScreen extends javax.swing.JFrame {

    private static javax.swing.JFrame parent;
    /** Creates new form ExitScreen */
    public ExitScreen() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

    	try {
			setIconImage(generalImages.getLogo());
		} catch (IOException e) {}
        exitText = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        exitOKButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setAlwaysOnTop(true);
        setResizable(false);

        exitText.setFont(new java.awt.Font("Roman", 1, 14));
        exitText.setText("Are you sure you want to exit Scrabble?");

        jButton2.setText("No (how can someone quit such a game???)");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        exitOKButton.setText("Yes");
        exitOKButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitOKButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(exitText, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton2)
                        .addGap(29, 29, 29)
                        .addComponent(exitOKButton)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(exitText)
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(exitOKButton, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        dispose();
}//GEN-LAST:event_jButton2ActionPerformed

    private void exitOKButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitOKButtonActionPerformed
        //all methods before exiting a game will be written here
        //use comp to close the screen and quit
    	GameGui.updateRecordList();
    	GameGui.saveRecordList('b');
    	GameGui.saveRecordList('a');
       parent.dispose();
       
        //close exitScreen
        this.dispose();
        System.exit(0);
}//GEN-LAST:event_exitOKButtonActionPerformed

        public static void startExitScreen(javax.swing.JFrame parent)
    {
        ExitScreen.parent = parent;
        ExitScreen exitScreen = new ExitScreen();
        exitScreen.setLocation(100, 100);
        exitScreen.setVisible(true);
    }
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ExitScreen().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton exitOKButton;
    private javax.swing.JLabel exitText;
    private javax.swing.JButton jButton2;
    // End of variables declaration//GEN-END:variables

}
